<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <div v-abc v-if='isIf'>{{msg}}</div>
    </div>
    <script src="../vue.js"></script>
    <script>
        let vm=new Vue({
            el:'#app',
            data () {
                return {
                    msg:'hello',
                    isIf:true,
                }
            },
            directives: {
                abc:{
                    bind(el,binding,vNode){//加载前触发 所以拿不到父结点
                        console.log('bind');
                        console.log(vNode);
                        console.log(el.parentNode); //null
                    },
                    inserted(el,binding,vNode){
                        console.log('inserted');
                        console.log(el.parentNode);  //可以拿到父结点
                    },
                    update(el,binding,vNode){
                        console.log('update');  //dom的内容、style等更新时触发
                    },
                    componentUpdate(el,binding,vNode){
                        console.log('componentUpdate');  //dom更新后触发
                    },
                    unbind(el,binding,vNode){  //只有在dom销毁时触发 可以通过v-if操作
                        console.log('unbind');  
                    }
                }
            }
        })
    </script>
</body>
</html>